<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .dian{
            width: 200px;
            margin: 0 auto;
            font-size: 100px;
            cursor: pointer;
            position: relative;
            z-index: 0;
            color: black;
        }
        .bk{
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, .8);
            position: fixed;
            top: 0;
            left: 0;
            z-index: 999;
            display: none;
        }
        .kuang{
            height: 400px;
            width: 600px;
            background-color: green;
            position: absolute;
            top: 200px;
            left: 500px;
            cursor: move;
        }
        .del{
            position: absolute;
            top: 0px;
            right: 0px;
            height: 20px;
            width: 20px;
            background-color: grey;
            text-align: center;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="bk">
        <div class="kuang">
            <div class="del">x</div>
        </div>
    </div>
    <div class="dian">点我</div>
    <script>
        var bk = document.querySelector('.bk');
        var dian = document.querySelector(".dian");
        var del = document.querySelector('.del');
        var kuang = document.querySelector('.kuang');
        dian.addEventListener('click',function(){
            bk.style.display = 'block';
            dian.style.color='rgba(0,0,0,.3)';
        })
        del.addEventListener('click',function(){
            bk.style.display = 'none';
            dian.style.color='rgb(0,0,0)';
            kuang.style.left = 500 + 'px';
            kuang.style.top = 200 + 'px';
        })
        kuang.addEventListener('mousedown',function(e){
            var mx = e.pageX - kuang.offsetLeft;
            var my = e.pageY - kuang.offsetTop;
            document.addEventListener('mousemove', move)
            function move(e){
                kuang.style.left = e.pageX - mx + 'px';
                kuang.style.top = e.pageY - my + 'px';
            }
            document.addEventListener('mouseup', function(){
                document.removeEventListener('mousemove',move);
            })
        })
    </script>
</body>
</html>